﻿CREATE view [dbo].[VersionDistributionLast30Days] as 

select (convert(datetime,cast(CheckDay as varchar(50)),112)) as CheckDay,(case when VersionStr is null then 'unknown' else VersionStr end)+' (#'+cast(ReleaseId as varchar(20))+')' as VersionStr,CheckCount,cast(CheckCount as float)/(select sum(CheckCount) from UpdateCheckDW b where a.CheckDay=b.CheckDay) as [Percent]
from UpdateCheckDW a
left outer join Releases
on a.ReleaseId=Releases.Id
where CheckDay between (
	cast(convert(varchar(50),dbo.LastDwUpdate()-31,112) as int)
) and (
	cast(convert(varchar(50),dbo.LastDwUpdate()-1,112) as int)
)
and PublicReleased<>0

